package com.googlecode.ozonbooksfinder.matefinder.business
{
	import com.googlecode.ozonbooksfinder.domain.SearchContext;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	public class AppStateManager extends EventDispatcher
	{
		private var _searchString:String;
		[Bindable(event="searchStringChange")]
		public function get searchString ():String
		{
			return _searchString;
		}

		private var _searchContext:String = SearchContext.DIV_BOOK;
		[Bindable(event="searchContextChange")]
		public function get searchContext ():String
		{
			return _searchContext;
		}

		public function setSearchContext (searchString:String, 
											searchContext:String):void
		{
			if (searchString != _searchString)
			{
				_searchString = searchString;
				dispatchEvent(new Event ("searchStringChange"));
			}
			if (searchContext != _searchContext)
			{
				_searchContext = searchContext;
				dispatchEvent(new Event ("searchContextChange"));
			}
		}
		
		private var _listViewMode:Boolean = false;
		[Bindable(event="listViewModeChange")]
		public function get listViewMode ():Boolean
		{
			return _listViewMode;
		}

		public function setListMode ():void
		{
			if (!_listViewMode)
			{
				_listViewMode = true;
				dispatchEvent (new Event ("listViewModeChange"));
			}
		}
		
		private var _searchMode:Boolean = true;
		[Bindable(event="searchModeChange")]
		public function get searchMode ():Boolean
		{
			return _searchMode;
		}

		public function setSearchMode (searchMode:Boolean):void
		{
			if (searchMode != _searchMode)
			{
				_searchMode = searchMode;
				dispatchEvent (new Event ("searchModeChange"));
			}
		}
	}
}